/* Version: 0.12.1 - May 5, 2025 14:33:25 */ /*! For license information please see shift4crypto-sdk.js.LICENSE.txt */ !function(){"use strict";!function(){const e={APP_URL:"https://crypto.shift4.com"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();var e=["https://js.dev.shift4.com/shift4.js","https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js"],t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};function n(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}var o,i=function(){return i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]A?A:eP?P:e1),F=[],U=!1,B=-1,W=void 0,j=void 0,K=void 0,N=function(e){return F.some((function(t){return!(!t.options.allowTouchMove||!t.options.allowTouchMove(e))}))},z=function(e){var t=e||window.event;return!!N(t.target)||(t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1))},q=function(e,t){if(e){if(!F.some((function(t){return t.targetElement===e}))){var n={targetElement:e,options:t||{}};F=[].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t=o&&(document.body.style.top=-(t+e))}))}),300)}})):function(e){if(void 0===K){var t=!!e&&!0===e.reserveScrollBarGap,n=window.innerWidth-document.documentElement.clientWidth;if(t&&n>0){var o=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);K=document.body.style.paddingRight,document.body.style.paddingRight=o+n+"px"}}void 0===W&&(W=document.body.style.overflow,document.body.style.overflow="hidden")}(t),_&&(e.ontouchstart=function(e){1===e.targetTouches.length&&(B=e.targetTouches[0].clientY)},e.ontouchmove=function(t){1===t.targetTouches.length&&function(e,t){var n=e.targetTouches[0].clientY-B;!N(e.target)&&(t&&0===t.scrollTop&&n>0||function(e){return!!e&&e.scrollHeight-e.scrollTop<=e.clientHeight}(t)&&n<0?z(e):e.stopPropagation())}(t,e)},U||(document.addEventListener("touchmove",z,D?{passive:!1}:void 0),U=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Y=function(){_&&(F.forEach((function(e){e.targetElement.ontouchstart=null,e.targetElement.ontouchmove=null})),U&&(document.removeEventListener("touchmove",z,D?{passive:!1}:void 0),U=!1),B=-1),_?function(){if(void 0!==j){var e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);document.body.style.position=j.position,document.body.style.top=j.top,document.body.style.left=j.left,window.scrollTo(t,e),j=void 0}}():(void 0!==K&&(document.body.style.paddingRight=K,K=void 0),void 0!==W&&(document.body.style.overflow=W,W=void 0)),F=[]},Z='\n \n \n \n ',Q=function(e){function t(t){var n=e.call(this,t)||this;n.overlay=null,n.isOpened=!1;var o=n.getDOMElements(),i=document.querySelector("body");if(!i)throw new Error("Unable to find body tag in the document");if(!o.element)throw new Error("Unable to get overlay DOM elements");return i.appendChild(o.element),n.handleEscapeKeydown=n.handleEscapeKeydown.bind(n),n}return n(t,e),t.prototype.show=function(){var e,t;if(this.isOpened)throw new Error("Overlay already opened");if(!this.overlay)throw new Error("Form not instantiated");this.overlay.open(),this.isOpened=!0,null===(t=null===(e=this.overlay)||void 0===e?void 0:e.element)||void 0===t||t.classList.add(I.visible),this.subscribeToKeyEvents(),this.overlay.element&&q(this.overlay.element)},t.prototype.close=function(){var e;if(!this.isOpened)throw new Error("Cannot close the overlay, it is not opened");if(!this.overlay)throw new Error("Unable to locate overlay, make sure you're not using embedded mode.");this.isOpened=!1,this.unsubscribeToKeyEvents(),Y(),null===(e=this.overlay.element)||void 0===e||e.classList.remove(I.visible),this.overlay.destroy()},t.prototype.getLoadingIndicator=function(){var e=document.createElement("div");e.classList.add(O.overlay);var t=this.getSpinner();return e.appendChild(t),e},t.prototype.getIframe=function(){var t=this,n=document.createElement("iframe");n.addEventListener("load",(function(){e.prototype.postDataFromConfig.call(t,n)}));var o=this.getIframeUrl();return n.setAttribute("src",o),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("frameborder","0"),n.setAttribute("allow","payment"),n},t.prototype.getDOMElements=function(){var e=this;if(this.overlay)return this.overlay;var t=document.createElement("div");t.id=L,t.classList.add(M.host);var n=document.createElement("div");n.classList.add(I.overlay);var o=this.getLoadingIndicator();n.appendChild(o);var i=this.getStyles();n.appendChild(i),t.attachShadow({mode:"open"}).appendChild(n);var r=this.getIframe(),a=document.createElement("div");a.classList.add(T.overlay),a.appendChild(r);var s=document.createElement("div");s.classList.add(I.contentWrapper),s.appendChild(a);var l=document.createElement("button");l.classList.add(I.closeButton),l.tabIndex=0,l.innerHTML=Z,s.appendChild(l),l.addEventListener("click",this.close.bind(this));var d=document.createElement("span");return d.classList.add(I.closeButtonText),d.innerHTML="Close",l.appendChild(d),this.overlay={element:n,open:function(){n.prepend(s),e.overlay.element=n},destroy:function(){n.removeChild(r),e.overlay.element=null}},this.overlay},t.prototype.handleEscapeKeydown=function(e){("Escape"===e.key||"Esc"===e.key||e.keyCode===S)&&this.close()},t.prototype.subscribeToKeyEvents=function(){window.addEventListener("keydown",this.handleEscapeKeydown)},t.prototype.unsubscribeToKeyEvents=function(){window.removeEventListener("keydown",this.handleEscapeKeydown)},t}(R),V=function(){function e(e,t){this.url=t,this.config=e,this.eventHandlers=this.initHandlers()}return e.prototype.initHandlers=function(){return Object.values(c).reduce((function(e,t){var n;return i(i({},e),((n={})[t]=[],n))}),{})},e.prototype.on=function(e,t){var n;return null===(n=this.eventHandlers[e])||void 0===n||n.push(t),this},e.prototype.append=function(e){return void 0===e?new Q({config:this.config,url:this.url,eventHandlers:this.eventHandlers}):new k({config:this.config,url:this.url,eventHandlers:this.eventHandlers},e)},e}(),G=function(){function e(){}return e.createForm=function(e){if(!(null==e?void 0:e.apiKey))throw new Error("Please provide a valid API key");return console.log("Form created with config: ",e),new V(e,g)},e}();window.Shift4CryptoSDK=G;e.forEach((function(e){var t=document.createElement("script");t.src=e,t.async=!0,document.head.appendChild(t)}))}();